home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 February / EnigmA AMIGA RUN 04 (1996)(G.R. Edizioni)(IT)[!][issue 1996-02][Skylink CD III].iso / earcd / util1 / syslog.lha / SysLog_V1.00 / Developer / examples / SysLog / SysLog.c < prev   
C/C++ Source or Header  |  1995-11-13  |  1KB  |  63 lines

  1. /*
  2.  * SysLog example
  3.  *
  4.  * This file is public domain.
  5.  *
  6.  * Author: Petri Nordlund <petrin@megabaud.fi>
  7.  *
  8.  * $Id: SysLog.c 1.3 1995/10/31 17:35:30 petrin Exp petrin $
  9.  *
  10.  *
  11.  * This program demostrates how to use the C link library routines to log messages.
  12.  *
  13.  */
  14.  
  15. #include <stdio.h>
  16. #include <stdlib.h>
  17. #include <proto/exec.h>
  18. #include <dos/dos.h>
  19. #include <libraries/syslog.h>
  20.  
  21.  
  22. int
  23. main(int argc, char **argv)
  24. {
  25.     LONG oldmask;
  26.  
  27.     /*
  28.      * Using SysLog is real easy:
  29.      */
  30.     SysLog(LOG_USER|LOG_NOTICE, "Test message. %d + %d = %d",1,2,3);
  31.  
  32.     /*
  33.      * If you're going to use SysLog a lot, you should call OpenLog() first.
  34.      * Add a "Test" tag to every message from now on. Include the PID in the
  35.      * message too. Facility is LOG_USER.
  36.      */
  37.     OpenLog("Test", LOG_PID, LOG_USER);
  38.  
  39.     /*
  40.      * No need to specify a facility anymore, altough it's possible.
  41.      */
  42.     SysLog(LOG_NOTICE, "Test message II. %d + %d = %d",4,5,9);
  43.  
  44.     /*
  45.      * From now on, only log messages with priority LOG_NOTICE or higher.
  46.      */
  47.     oldmask = SetLogMask(LOG_UPTO(LOG_NOTICE));
  48.  
  49.     /*
  50.      * This message won't get logged because LOG_INFO has lower priority
  51.      * than LOG_NOTICE.
  52.      */
  53.     SysLog(LOG_INFO, "Test message III. You see I'm real good at math");
  54.  
  55.     /*
  56.      * This doesn't do anything now, but it may do something in the future, so
  57.      * make sure you call it if you have called OpenLog()
  58.      */
  59.     CloseLog();
  60.  
  61.     return(RETURN_OK);
  62. }
  63.